@extends('layouts.master')

@section('title')
    Tipo de partidos
@stop

@section('content')
<div class="row">
	<div class="col-lg-12">
        <p><a class="btn btn-default" href="{{ URL::to('matchTypes/create') }}"><i class="fa fa-plus-square"></i> Nuevo tipo</a></p>
		<section class="panel">
            <div class="table-responsive">
				<table class="table table-striped m-b-none" data-ride="datatables">
					<thead>
						<tr>
							<th>ID</th>
							<th>Nombre</th>
							<th>Cantidad total de jugadores</th>
							<th>Vs.?</th>
							<th>Actions</th>
						</tr>
					</thead>
					<tbody>
					<!-- display stored match types -->
					@foreach($matchTypes as $key => $value)
						<tr>
							<td>{{ $value->id }}</td>
							<td>{{ $value->name }}</td>
							<td>{{ $value->totalPlayers }}</td>
							<td><input style="height: auto; width: auto;" type="checkbox" disabled="true" <?php if($value->versus) echo "checked='checked'" ?> /></td>
				
							<!-- we will also add show, edit, and delete buttons -->
							<td>
								<a class="btn btn-small btn-info" href="{{ URL::to('matchTypes/' . $value->id . '/edit') }}">Editar</a>
								
								{{ Form::button('Eliminar', array(
				                	'onclick' =>    'showConfirmDeleteModal(
				                    	"' . $value->name . '",
				                        "' . url('matchTypes/' . $value->id) . '"
				                	)',
				                    'class' => 'btn btn-danger',
				                 )) }}
							</td>
						</tr>
					@endforeach
					</tbody>
				</table>
            </div>
    	</section>
	</div>
</div>
@stop

@section('modals')
 {{-- Modal: Confirm delete --}}
    <div class="modal fade" id="modal-confirmDelete" tabindex="-1" role="dialog" aria-labelledby="confirmDelete" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h3 class="modal-title">Eliminar</h3>
                </div>
                <div class="modal-body">
                    <p>
                        <strong>Esta seguro que desea eliminar este elemento?</strong>
                    </p>
                    <p id="deletePageName" class="text-danger"></p>
                </div>
                <div class="modal-footer">
                    {{ Form::open(array('id' => 'deleteForm', 'method' => 'delete')) }}
                        {{ Form::button('Cancelar', array(
                            'data-dismiss' => 'modal',
                            'class' => 'btn btn-default',
                        )) }}
                        {{ Form::submit('Eliminar', array(
                            'class' => 'btn btn-default',
                        )) }}
                    {{ Form::close() }}
                </div>
            </div>{{-- /.modal-content --}}
        </div>{{-- /.modal-dialog --}}
    </div>{{-- /.modal --}}
@stop

@section('scripts')
<script>
	function showConfirmDeleteModal(name, url) {
    	$('#deleteForm').prop('action', url);
        $('#deletePageName').text(name);

        $('#modal-confirmDelete').modal({
        	show: true
        });
	}

	// datatable
	$('[data-ride="datatables"]').each(function() {
		var oTable = $(this).dataTable( {
			"sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col col-sm-6'p>>",
			"sPaginationType": "full_numbers",
			"language": {
	            "lengthMenu": "Mostrar _MENU_ registros por página",
	            "zeroRecords": "No se encontraron resultados",
	            "info": "Mostrando página _PAGE_ de _PAGES_",
	            "infoEmpty": "No hay datos para mostrar",
	            "infoFiltered": "(filtrado de un total de _MAX_ registros)"
	        },
	        "aoColumnDefs": [
	                       {
	                          bSortable: false,
	                          aTargets: [ -1 ]
	                       }
	                     ]
		} );
	});
</script>	
@stop